package com.mysteel.seckill.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * ProjectName: mail
 * ClassName: RedissonConfig
 * Description:
 * date: 2021/01/27/027 11:17
 *
 * @author xiaochao
 */
@Configuration
public class RedissonConfig {

    /**
     * 所有对redisson的使用都是通过RedissonClient调用
     * @return
     * @throws IOException
     */
    @Bean(destroyMethod="shutdown")
    public RedissonClient redisson() throws IOException {
        // 创建Redisson单节点配置
        Config config = new Config();
        config.useSingleServer().setAddress("redis://47.99.133.178:6379").setPassword("123456").setConnectionMinimumIdleSize(10);
        return Redisson.create(config);
    }

}
